package com.lic.system.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lic.system.common.Result;
import com.lic.system.pojo.LicensePram;
import com.lic.system.service.LicenseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;

/**
 * @author Hewb
 * @ClassName: userController
 * @Description: TODO
 * @date: 2020/7/11 9:32
 * @since JDK 1.8
 */
@RestController
@RequestMapping("license")
public class licenseController {

    @Autowired
    LicenseService licenseService;

    @GetMapping("selectLicense")
    public Result selectLicense(int pageSize, int limitSize, LicensePram licensePram) {
        try{
            HashMap<String, Object> hashMap = new HashMap<>();
            Page<LicensePram> licensePramPage = new Page<>(pageSize,limitSize);
            Page<LicensePram> licensePrams = licenseService.selectLicense(licensePramPage,licensePram);
            hashMap.put("data", licensePrams.getRecords());
            hashMap.put("count", licensePrams.getTotal());
            return Result.ok(hashMap);
        }catch (Exception e){
            return  Result.error(e.getMessage());
        }

    }

}
